home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-01 | 16.1 KB | 520 lines | [TEXT/MPS ] |
- ;
- ; File: NumberFormatting.a
- ;
- ; Version: Technology: 8.0
- ; Release: Universal Interfaces 3.0d3 on Copland DR1
- ;
- ; Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved.
- ;
- ; Bugs?: If you find a problem with this file, send the file and version
- ; information (from above) and the problem description to:
- ;
- ; Internet: apple.bugs@applelink.apple.com
- ; AppleLink: APPLE.BUGS
- ;
- ;
- IF &TYPE('__NUMBERFORMATTING__') = 'UNDEFINED' THEN
- __NUMBERFORMATTING__ SET 1
-
- IF &TYPE('__CONDITIONALMACROS__') = 'UNDEFINED' THEN
- include 'ConditionalMacros.a'
- ENDIF
- IF &TYPE('__TYPES__') = 'UNDEFINED' THEN
- include 'Types.a'
- ENDIF
- IF FOR_SYSTEM8_PREEMPTIVE THEN
- IF &TYPE('__TEXTOBJECTS__') = 'UNDEFINED' THEN
- include 'TextObjects.a'
- ENDIF
- IF &TYPE('__TEXTCOMMON__') = 'UNDEFINED' THEN
- include 'TextCommon.a'
- ENDIF
- IF &TYPE('__LOCALEOBJECTS__') = 'UNDEFINED' THEN
- include 'LocaleObjects.a'
- ENDIF
- IF &TYPE('__TEXTPARSER__') = 'UNDEFINED' THEN
- include 'TextParser.a'
- ENDIF
- ENDIF
- IF FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE THEN
- IF &TYPE('__INTLRESOURCES__') = 'UNDEFINED' THEN
- include 'IntlResources.a'
- ENDIF
- ENDIF
- ;
- ;
- ; Here are the current System 7 routine names and the translations to the older forms.
- ; Please use the newer forms in all new code and migrate the older names out of existing
- ; code as maintainance permits.
- ;
- ; New Name Old Name(s)
- ;
- ; ExtendedToString FormatX2Str
- ; FormatRecToString Format2Str
- ; NumToString
- ; StringToExtended FormatStr2X
- ; StringToFormatRec Str2Format
- ; StringToNum
- ;
- ;
- IF FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE THEN
- NumFormatString RECORD 0
- fLength ds.b 1 ; offset: $0 (0)
- fVersion ds.b 1 ; offset: $1 (1)
- data ds.b 254 ; offset: $2 (2) ; private data
- sizeof EQU * ; size: $100 (256)
- ENDR
- NumFormatStringRec RECORD 0
- f ds NumFormatString
- sizeof EQU * ; size: $100 (256)
- ENDR
-
-
- ENDIF
- IF FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE THEN
- ; typedef short FormatStatus
-
-
- fVNumber EQU 0 ; first version of NumFormatString
- ; typedef SInt8 FormatClass
-
-
- fPositive EQU 0
- fNegative EQU 1
- fZero EQU 2
- ; typedef SInt8 FormatResultType
-
-
- fFormatOK EQU 0
- fBestGuess EQU 1
- fOutOfSynch EQU 2
- fSpuriousChars EQU 3
- fMissingDelimiter EQU 4
- fExtraDecimal EQU 5
- fMissingLiteral EQU 6
- fExtraExp EQU 7
- fFormatOverflow EQU 8
- fFormStrIsNAN EQU 9
- fBadPartsTable EQU 10
- fExtraPercent EQU 11
- fExtraSeparator EQU 12
- fEmptyFormatString EQU 13
- FVector RECORD 0
- start ds.w 1 ; offset: $0 (0)
- length ds.w 1 ; offset: $2 (2)
- sizeof EQU * ; size: $4 (4)
- ENDR
- ; index by [fPositive..fZero]
- TripleInt RECORD 0
- elements ds.b 3 * FVector.sizeof
- sizeof EQU * ; size: $C (12)
- ENDR
-
-
- ENDIF
- IF FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE THEN
- ;
- ; pascal void StringToNum(ConstStr255Param theString, long *theNum)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _StringToNum
- move.w #$0001,-(sp)
- dc.w $A9EE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION StringToNum
- ENDIF
-
- ;
- ; pascal void NumToString(long theNum, Str255 theString)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _NumToString
- move.w #$0000,-(sp)
- dc.w $A9EE
- EndM
- ELSE
- IMPORT_CFM_FUNCTION NumToString
- ENDIF
-
- ENDIF
- IF FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE THEN
- ;
- ; pascal FormatStatus ExtendedToString(extended80 *x, const NumFormatString *myCanonical, const NumberParts *partsTable, Str255 outString)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _ExtendedToString
- move.l #$8210FFE8,-(sp)
- dc.w $A8B5
- EndM
- ELSE
- IMPORT_CFM_FUNCTION ExtendedToString
- ENDIF
-
- ;
- ; pascal FormatStatus StringToExtended(ConstStr255Param source, const NumFormatString *myCanonical, const NumberParts *partsTable, extended80 *x)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _StringToExtended
- move.l #$8210FFE6,-(sp)
- dc.w $A8B5
- EndM
- ELSE
- IMPORT_CFM_FUNCTION StringToExtended
- ENDIF
-
- ;
- ; pascal FormatStatus StringToFormatRec(ConstStr255Param inString, const NumberParts *partsTable, NumFormatString *outString)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _StringToFormatRec
- move.l #$820CFFEC,-(sp)
- dc.w $A8B5
- EndM
- ELSE
- IMPORT_CFM_FUNCTION StringToFormatRec
- ENDIF
-
- ;
- ; pascal FormatStatus FormatRecToString(const NumFormatString *myCanonical, const NumberParts *partsTable, Str255 outString, TripleInt positions)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _FormatRecToString
- move.l #$8210FFEA,-(sp)
- dc.w $A8B5
- EndM
- ELSE
- IMPORT_CFM_FUNCTION FormatRecToString
- ENDIF
-
- ENDIF
- IF OLDROUTINENAMES THEN
- IF FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED THEN
- ENDIF
- ; FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
- ENDIF
- ; OLDROUTINENAMES
- IF FOR_SYSTEM8_PREEMPTIVE THEN
- ; typedef LocaleObjectRef LocaleNumberFormatterObjectRef
-
- ; typedef OptionBits NumberFormatterOptionBits
-
- ; typedef UInt32 NumberFormatterTokenID
-
- FIndexVector RECORD 0
- startIndex ds.l 1 ; offset: $0 (0)
- endIndex ds.l 1 ; offset: $4 (4)
- sizeof EQU * ; size: $8 (8)
- ENDR
- ; index by [fPositive..fZero]
- TripleIndex RECORD 0
- elements ds.b 3 * FIndexVector.sizeof
- sizeof EQU * ; size: $18 (24)
- ENDR
-
-
-
- ;NumberFormatterOptionBits
- kDontUseThousandSeparatorBit EQU 0
- kIsScientificFormatBit EQU 1
- kIsPercentageFormatBit EQU 2
- kIsCurrencyFormatBit EQU 3
- kIsFractionCurrencyFormatBit EQU 4
- kIsLongFormCurrencyFormatBit EQU 5
- kOmitDecimalPointInCurrencyFormatBit EQU 6
- kUseAsciiDigitBit EQU 7
- kUseNegativePosfixPrefixBit EQU 8
-
- ;NumberFormatterOptionBits
- kStandardFormatMask EQU 0
- kDontUseThousandSeparatorMask EQU $00000001
- kIsScientificFormatMask EQU $00000002
- kIsPercentageFormatMask EQU $00000004
- kIsCurrencyFormatMask EQU $00000008
- kIsFractionCurrencyFormatMask EQU $00000010
- kIsLongFormCurrencyFormatMask EQU $00000020
- kOmitDecimalPointInCurrencyFormatMask EQU $00000040
- kUseAsciiDigitMask EQU $00000080
- kUseNegativePosfixPrefixMask EQU $00000100
- ;
- ; extern OSStatus GetNumberFormatterObjectFromRef(LocaleRef locale, LocaleNumberFormatterObjectRef *numberFormatterObject)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION GetNumberFormatterObjectFromRef
- ENDIF
-
- ;
- ; extern OSStatus GetNumberFormatterObjectFromID(LocaleIdentifier localeID, LocaleNumberFormatterObjectRef *numberFormatterObject)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION GetNumberFormatterObjectFromID
- ENDIF
-
- ;
- ; extern OSStatus GetCurrentNumberFormatterObject(LocaleNumberFormatterObjectRef *numberFormatterObject)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION GetCurrentNumberFormatterObject
- ENDIF
-
- ;
- ; extern OSStatus GetNumberFormatterObjectInfo(LocaleNumberFormatterObjectRef numberFormatterObject, TextEncoding *theEncoding, LocaleIdentifier *theLocaleIdentifier)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION GetNumberFormatterObjectInfo
- ENDIF
-
- ;
- ; extern OSStatus ConvertUInt32ToTextObject(UInt32 theUInt32, LocaleNumberFormatterObjectRef numberFormatterObject, NumberFormatterOptionBits options, TextObject theTextObject, TextObjectIndex startReplaceIndex, TextObjectIndex endReplaceIndex)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION ConvertUInt32ToTextObject
- ENDIF
-
- ;
- ; extern OSStatus ConvertSInt32ToTextObject(SInt32 theSInt32, LocaleNumberFormatterObjectRef numberFormatterObject, NumberFormatterOptionBits options, TextObject theTextObject, TextObjectIndex startReplaceIndex, TextObjectIndex endReplaceIndex)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION ConvertSInt32ToTextObject
- ENDIF
-
- ;
- ; extern OSStatus ConvertUInt64ToTextObject(UInt64 theUInt64, LocaleNumberFormatterObjectRef numberFormatterObject, NumberFormatterOptionBits options, TextObject theTextObject, TextObjectIndex startReplaceIndex, TextObjectIndex endReplaceIndex)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION ConvertUInt64ToTextObject
- ENDIF
-
- ;
- ; extern OSStatus ConvertSInt64ToTextObject(SInt64 theSInt64, LocaleNumberFormatterObjectRef numberFormatterObject, NumberFormatterOptionBits options, TextObject theTextObject, TextObjectIndex startReplaceIndex, TextObjectIndex endReplaceIndex)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION ConvertSInt64ToTextObject
- ENDIF
-
- ;
- ; extern OSStatus ConvertDoubleToTextObject(double theDouble, LocaleNumberFormatterObjectRef numberFormatterObject, NumberFormatterOptionBits options, SInt8 precision, TextObject theTextObj, TextObjectIndex startReplaceIndex, TextObjectIndex endReplaceIndex)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION ConvertDoubleToTextObject
- ENDIF
-
- ;
- ; extern OSStatus ConvertTextObjectToUInt32(ConstTextObject textObject, LocaleNumberFormatterObjectRef numberFormatterObject, NumberFormatterOptionBits options, TextObjectIndex startIndex, TextObjectIndex endIndex, UInt32 *theUInt32)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION ConvertTextObjectToUInt32
- ENDIF
-
- ;
- ; extern OSStatus ConvertTextObjectToSInt32(ConstTextObject textObject, LocaleNumberFormatterObjectRef numberFormatterObject, NumberFormatterOptionBits options, TextObjectIndex startIndex, TextObjectIndex endIndex, SInt32 *theSInt32)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION ConvertTextObjectToSInt32
- ENDIF
-
- ;
- ; extern OSStatus ConvertTextObjectToUInt64(ConstTextObject textObject, LocaleNumberFormatterObjectRef numberFormatterObject, NumberFormatterOptionBits options, TextObjectIndex startIndex, TextObjectIndex endIndex, UInt64 *theUInt64)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION ConvertTextObjectToUInt64
- ENDIF
-
- ;
- ; extern OSStatus ConvertTextObjectToSInt64(ConstTextObject textObject, LocaleNumberFormatterObjectRef numberFormatterObject, NumberFormatterOptionBits options, TextObjectIndex startIndex, TextObjectIndex endIndex, SInt64 *theSInt64)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION ConvertTextObjectToSInt64
- ENDIF
-
- ;
- ; extern OSStatus ConvertTextObjectToDouble(ConstTextObject textObject, LocaleNumberFormatterObjectRef localeObjectRef, TextObjectIndex startIndex, TextObjectIndex endIndex, double *theDouble)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION ConvertTextObjectToDouble
- ENDIF
-
- ;
- ; extern OSStatus FormattedTextObjectToDouble(ConstTextObject textObject, LocaleNumberFormatterObjectRef ref, TextObjectIndex startIndex, TextObjectIndex endIndex, const NumFormatString *myCanonical, const double *num)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION FormattedTextObjectToDouble
- ENDIF
-
- ;
- ; extern OSStatus DoubleToFormattedTextObject(double *num, LocaleNumberFormatterObjectRef ref, const NumFormatString *myCanonical, TextObject outTextObject)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION DoubleToFormattedTextObject
- ENDIF
-
- ;
- ; extern OSStatus TextObjectToFormatRec(ConstTextObject textObject, LocaleNumberFormatterObjectRef ref, TextObjectIndex startIndex, TextObjectIndex endIndex, NumFormatString *outString)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION TextObjectToFormatRec
- ENDIF
-
- ;
- ; extern OSStatus FormatRecToTextObject(const NumFormatString *myCanonical, LocaleNumberFormatterObjectRef ref, TextObject outTextObject, TripleIndex positions)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION FormatRecToTextObject
- ENDIF
-
-
- ; NumberFormatterTokenID
- kNumFmtCharLeftQuote EQU 0 ;(begin literal)
- kNumFmtCharRightQuote EQU 1 ;(end literal)
- kNumFmtCharLeadPlacer EQU 2 ; (‘^’ in U.S)
- kNumFmtCharLeader EQU 3 ;(non-breakable space in U.S)
- kNumFmtCharNonLeader EQU 4 ;(# sign in U.S)
- kNumFmtCharZeroLead EQU 5 ;(digit ‘0’ in U.S)
- kNumFmtCharCurrencyPlacer EQU 6 ; (‘$’ in U.S)
- kNumFmtCharPercent EQU 7 ; (‘%’)
- kNumFmtCharPlusSign EQU 8 ; (‘+’)
- kNumFmtCharMinusSign EQU 9 ; (‘-’)
- kNumFmtCharThousandSep EQU 10 ; (‘,’)
- kNumFmtCharFormatSeparator EQU 11 ; (‘;’)
- kNumFmtCharEscape EQU 12 ; (‘\’)
- kNumFmtCharDecPoint EQU 13 ; (‘.’)
- kNumFmtTextpePlus EQU 14 ; (‘E+’)
- kNumFmtTextpeMinus EQU 15 ; (‘E-’)
- kNumFmtTextMinusPlus EQU 16 ; (‘E’)
- kNumFmtTextFirstRangeCurrencyForm EQU 17 ; (‘Dollar’)
- kNumFmtTextSecondRangeCurrencyForm EQU 18 ; (‘Dollar(s)’)
- kNumFmtTextPluralCurrency EQU 19 ; (‘Dollar(s)’)
- kNumFmtTextfractionCurrency EQU 20 ; (‘cents))
- kNumFmtTextCurrencyAbbreviated EQU 21 ; (‘$’)
- kNumFmtTextfractionCurrencyAbbreviated EQU 22 ; (‘¢’)
- kNumFmtTextNegativePrefix EQU 23 ; (‘(‘)
- kNumFmtTextNegativePostfix EQU 24 ; (‘)’)
- ; typedef UInt32 CurrencyPosition
-
-
- ;CurrencyPosition
- kAtTheBeginning EQU 0
- kAtDecimalPointPosition EQU 1
- kAtTheEnd EQU 2
- ;
- ; extern OSStatus CreateCustomNumberFormatLocaleObject(LocaleNumberFormatterObjectRef numberFormatterObject, LocaleNumberFormatterObjectRef *customNumberFormatterObject)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION CreateCustomNumberFormatLocaleObject
- ENDIF
-
- ;
- ; extern OSStatus DeleteCustomNumberFormatLocaleObject(LocaleNumberFormatterObjectRef customNumberFormatterObject)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION DeleteCustomNumberFormatLocaleObject
- ENDIF
-
- ;
- ; extern OSStatus SetNumFmtTokenToParserToken(LocaleNumberFormatterObjectRef customNumberFormatterObject, NumberFormatterTokenID tokenID, BasicToken theToken)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION SetNumFmtTokenToParserToken
- ENDIF
-
- ;
- ; extern OSStatus GetParserTokenFromNumFmtToken(LocaleNumberFormatterObjectRef customNumberFormatterObject, NumberFormatterTokenID tokenID, BasicToken *theToken)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION GetParserTokenFromNumFmtToken
- ENDIF
-
- ;
- ; extern OSStatus GetNumberFormatterTextFromToken(LocaleNumberFormatterObjectRef customNumberFormatterObject, NumberFormatterTokenID tokenID, TextObject theTextObject)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION GetNumberFormatterTextFromToken
- ENDIF
-
- ;
- ; extern OSStatus SetNumFmtTokenToText(LocaleNumberFormatterObjectRef customNumberFormatterObject, NumberFormatterTokenID tokenID, ConstTextObject theTextObject)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION SetNumFmtTokenToText
- ENDIF
-
- ;
- ; extern OSStatus GetLocaleLongCurrencyPosition(LocaleNumberFormatterObjectRef customNumberFormatterObject, CurrencyPosition *position)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION GetLocaleLongCurrencyPosition
- ENDIF
-
- ;
- ; extern OSStatus SetLocaleLongCurrencyPosition(LocaleNumberFormatterObjectRef customNumberFormatterObject, CurrencyPosition position)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION SetLocaleLongCurrencyPosition
- ENDIF
-
- ;
- ; extern OSStatus GetLocaleAbbrevCurrencyPosition(LocaleNumberFormatterObjectRef customNumberFormatterObject, CurrencyPosition *position)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION GetLocaleAbbrevCurrencyPosition
- ENDIF
-
- ;
- ; extern OSStatus SetLocaleAbbrevCurrencyPosition(LocaleNumberFormatterObjectRef customNumberFormatterObject, CurrencyPosition position)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION SetLocaleAbbrevCurrencyPosition
- ENDIF
-
- ;
- ; extern OSStatus GetLocaleFirstRangeCurrency(LocaleNumberFormatterObjectRef customNumberFormatterObject, UInt32 *maxValueInRange)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION GetLocaleFirstRangeCurrency
- ENDIF
-
- ;
- ; extern OSStatus SetLocaleFirstRangeCurrency(LocaleNumberFormatterObjectRef customNumberFormatterObject, UInt32 maxValueInRange)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION SetLocaleFirstRangeCurrency
- ENDIF
-
- ;
- ; extern OSStatus GetLocaleSecondRangeCurrency(LocaleNumberFormatterObjectRef customNumberFormatterObject, UInt32 *maxValueInRange)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION GetLocaleSecondRangeCurrency
- ENDIF
-
- ;
- ; extern OSStatus SetLocaleSecondRangeCurrency(LocaleNumberFormatterObjectRef customNumberFormatterObject, UInt32 maxValueInRange)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION SetLocaleSecondRangeCurrency
- ENDIF
-
- ;
- ; extern OSStatus GetLocaleDigitText(LocaleNumberFormatterObjectRef customNumberFormatterObject, UInt8 theDigit, TextObject theTextObject)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION GetLocaleDigitText
- ENDIF
-
- ;
- ; extern OSStatus SetLocaleDigitText(LocaleNumberFormatterObjectRef customNumberFormatterObject, UInt8 theDigit, TextObject theTextObject)
- ;
- IF GENERATINGCFM THEN
- IMPORT_CFM_FUNCTION SetLocaleDigitText
- ENDIF
-
- ENDIF
- ENDIF ; __NUMBERFORMATTING__
-
-